package service.impl.v2;

import java.io.UnsupportedEncodingException;
import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;

import dao.v2.AddressVOMapper;
import dao.v2.ConfigVOMapper;
import dao.v2.MemberLevelItemVOMapper;
import dao.v2.MemberVOMapper;
import model.AddressVO;
import model.LogPackageVO;
import model.MemberMsgVO;
import model.MemberVO;
import model.PackageVO;
import model.PageEarnVO;
import service.v2.DicService;
import service.v2.MemberService;
import service.v2.PushService;
import util.DateParseUtil;
import util.DeliverUtil;
import util.NumberUtil;
import util.OssUtil;
import util.PropertieUtil;
@Service
public class MemberServiceImpl implements MemberService {
	@Autowired
	private MemberVOMapper dao;
	@Autowired
	private ConfigVOMapper configDao;
	@Autowired
	private MemberLevelItemVOMapper MemberLevelItemVOMapper;
	@Autowired
	private PushService pushservice;
	@Autowired
	private DicService dicService;
	@Autowired
	private AddressVOMapper addressVOMapper;

	public MemberVO getMemberByTel(MemberVO memberVO) {
		return dao.getMemberByTel(memberVO) ;
	}

	public MemberVO login(MemberVO memberVO) {
		return dao.login(memberVO);
	}

	public void updateTokenAndLogin(Map<String, String> map) {
		dao.updateTokenAndLogin(map) ;
	}

	public MemberVO smsLogin(MemberVO memberVO) {
		return dao.smsLogin(memberVO);
	}

	public int insert(MemberVO memberVO) {
		if (memberVO.getPwd()==null) {
			memberVO.setPwd("");
		}
		return dao.insert(memberVO);
	}

	public void updatePwd(MemberVO memberVO) {
		dao.updatePwd(memberVO);
	}

	public MemberVO getLevelByMemberId(String member_id) {
		return dao.getLevelByMemberId(member_id);
	}

	public String getSpecificChildNum(String member_id, String master_id) {
		return dao.getSpecificChildNum(member_id, master_id) ;
	}
	
	public String getChildrenNum(String id) {
		String re=dao.getChildIds(id);
		return dao.getChildrenNum(id,re) ;
	}

	public MemberVO getMasterMemberInfo(String member_id) {
		return dao.getMasterMemberInfo(member_id) ;
	}
	
	public MemberVO getCurMemberInfo(String member_id) {
		return dao.getCurMemberInfo(member_id) ;
	}
	
	public List<MemberVO> getLevlupInfo(String loadPropertie, String history_total_ticket) {
		return dao.getLevlupInfo(loadPropertie,history_total_ticket);
	}
	
	public MemberVO getLoginMemberById(String id) {
		return dao.getLoginMemberById(id);
	}
	
	public void updateTel(MemberVO memberVO) {
		dao.updateTel(memberVO);
	}
	
	public int checkTel(MemberVO memberVO) {
		return dao.checkTel(memberVO);
	}
	
	public int checkPwd(MemberVO memberVO) {
		return dao.checkPwd(memberVO);
	}
	
	public void updatePwdById(MemberVO memberVO) {
		dao.updatePwdById( memberVO);
	}
	
	public void updatePayPwdById(MemberVO memberVO) {
		dao.updatePayPwdById(memberVO);
	}
	public void updateIdCardInfo(MemberVO memberVO) {
		dao.updateIdCardInfo(memberVO);
	}
	public MemberVO getMemberByTelNoInviteno(MemberVO memberVO) {
		return dao.getMemberByTelNoInviteno(memberVO);
	}
	public void updateMemberInfo(MemberVO memberVO) {
		dao.updateMemberInfo(memberVO);
	}
	public MemberVO getMemberInfoByTel(String tel) {
		return dao.getMemberInfoByTel(tel) ;
	}
	public MemberVO getIdcardInfo(String member_id) {
		return dao.getIdcardInfo(member_id);
	}
	public int checkMemberInChildren(String id, String member_id) {
		return dao.checkMemberInChildren(id, member_id);
	}
	public void updateInvitedBy(MemberVO memberVO) {
		//修改推荐人
		dao.updateInvitedBy(memberVO) ;
		//
		//成功邀请下线推送
		memberVO = dao.getAllInfoById(memberVO.getId());
		pushservice.pushChangeInvitedByMsg(memberVO);
	}
	public int checkTokenTime(String token, String member_id) {
		return dao.checkTokenTime(token, member_id);
	}
	public MemberVO getDrawAccount(String member_id) {
		return dao.getDrawAccount(member_id);
	}
	public void updateDrawAccountAlipay(String member_id,String type, String account, String name, String bank_id) {
		dao.updateDrawAccountAlipay( member_id,type,  account,  name,  bank_id) ;
	}
	public int chekPayPwd(MemberVO memberVO) {
		return dao.chekPayPwd(memberVO);
	}
	public int checkFreeCash(MemberVO memberVO) {
		return dao.checkFreeCash( memberVO);
	}

	public String selectSpecialYn(String member_id) {
		return dao.selectSpecialYn(member_id);
	}
	public MemberVO checkLoginTime(String member_id, String day_num, String os) {
		return dao.checkLoginTime( member_id,  day_num, os) ;
	}
	public void updateLastLoginTime(String member_id, String os) {
		int num = dao.checkTimeOverOneHour(member_id, os);
		if(num > 0){
			dao.updateLastLoginTime(member_id,  os);
		}
	}
	public MemberVO getInvitedMemberInfo(String member_id) {
		return dao.getInvitedMemberInfo(member_id);
	}
	public List<MemberVO> getChildListByParent(MemberVO memberVO) {
		return dao.getChildListByParent( memberVO);
	}
	public MemberVO getInfoById(String parent_id) {
		return dao.getInfoById( parent_id);
	}
	public int getTotal(MemberVO memberVO) {
		return dao.getTotal( memberVO);
	}
	public MemberVO getAllInfoById(String member_id) {
		return dao.getAllInfoById( member_id);
	}
	public MemberVO getLoginMemberByOpenId(String open_id) {
		return dao.getLoginMemberByOpenId(open_id);
	}
	@Override
	public MemberVO getLoginMemberByGoogleId(String google_id) {
		return dao.getLoginMemberByGoogleId(google_id);
	}
	public int getPackage(String package_id) {
		// TODO Auto-generated method stub
		return dao.getPackage(package_id);
	}

	public void insertLogPackage(LogPackageVO log) {
		// TODO Auto-generated method stub
		dao.insertLogPackage(log);
	}
	
	public boolean checkRealName(String type, String member_id) {
		MemberVO memberVO = dao.getAllInfoById(member_id);
		if("1".equals(type) && memberVO.getName() != null && memberVO.getName().equals(memberVO.getAlipay_name())){
			return true;
		}else if("2".equals(type) && memberVO.getName() != null &&memberVO.getName().equals(memberVO.getBank_card_name()) ){
			return true;
		}
		return false;
	}

	public void updMemberLevel(String member_id, String vip_level, String level, String primary_level) {
		// TODO Auto-generated method stub
		dao.updMemberLevel(member_id,vip_level,level,primary_level);
	}

	public double getCurMonthProfit(String member_id) {
		return dao. getCurMonthProfit( member_id) ;
	}
	
	public void regPushId(String member_id, String push_id) {
		dao.regPushId( member_id,  push_id) ;
	}

	public PackageVO getGoodPackage(String pakcage_id,String standard_id) {
		return dao.getGoodPackage(pakcage_id,standard_id);
	}
	public int checkInviteNo(String invite_no) {
		return dao.checkInviteNo( invite_no);
	}

	public MemberVO getMemberInfoById(String invite_no) {
		return  dao.getMemberInfoById(invite_no);
	}
	
	public void updateOpenId(MemberVO vo) {
		dao.updateOpenId(vo);
	}
	public void updateQQId(MemberVO memberVO) {
		dao.updateQQId(memberVO);
	}
	public void updateSinaId(MemberVO memberVO) {
		dao.updateSinaId(memberVO);
	}
	
	public String getInvitenoByOpenid(String open_id) {
		return dao.getInvitenoByOpenid(open_id);
	}

	public PackageVO getGoodPackageNostandardId(String pakcage_id) {
		// TODO Auto-generated method stub
		return dao.getGoodPackageNostandardId(pakcage_id);
	}
	
	public String getAlipayFee(String string) {
		return dao.getAlipayFee(string) ;
	}

	public String selectMemberOpenid(String member_id) {
		return dao.selectMemberOpenid(member_id);
	}
	
	public int getMemberNumByTel(MemberVO memberVO) {
		return dao.getMemberNumByTel( memberVO) ;
	}
	
	public void deleteMember(String id) {
		dao.deleteMember(id);
	}

	public double getfreeCash(String member_id) {
		return dao.getfreeCash(member_id);
	}
	public void updatePersonalSign(MemberVO memberVO) {
		dao.updatePersonalSign(memberVO);
	}
	public MemberVO getSimpleInfoById(String member_id) {
		return dao.getSimpleInfoById(member_id);
	}
	public MemberVO getMemberByIdWechat(String member_id, String token) {
		return dao.getMemberByIdWechat(member_id ,token);
	}

	public void updataMyWindowShareTimes(String member_id) {
		dao.updataMyWindowShareTimes(member_id);
	}

	public JSONObject checkIdcardApprove(MemberVO memberVO) {
		JSONObject msg = new JSONObject();
		MemberVO vo=dao.getAllInfoById(memberVO.getId());
		if(!"4".equals(vo.getIdcard_state())){
			String key_value=configDao.loadConfig("REAL_NAME_AUTHENTICATION_KEY");
			
			try {
				String name_encode=java.net.URLEncoder.encode(memberVO.getName(),"utf-8");
				String result = DeliverUtil.HttpRequest("http://op.juhe.cn/idcard/query?key="+key_value+"&idcard="+memberVO.getIdcard()+"&realname="+name_encode, HttpMethod.POST, "","");
				msg = JSONObject.parseObject(result);
				System.out.println(msg);
				if("0".equals(msg.get("error_code").toString())){
					JSONObject o = (JSONObject) msg.get("result");
					System.out.println(o.get("res"));
					if(("1").equals(o.get("res").toString())){
						if(memberVO.getIdcard_front_img()==null && memberVO.getIdcard_back_img()==null){
							if(vo.getIdcard_front_img()!=null&&vo.getIdcard_back_img()!=null){
								OssUtil.deleteFile(vo.getIdcard_front_img());
								OssUtil.deleteFile(vo.getIdcard_back_img());
							}
						}
						memberVO.setIdcard_state("4");
						memberVO.setIdcard_reason("完成实名认证");
						dao.newUpdateIdCardInfo(memberVO);
					}else{
						memberVO.setIdcard_state("3");
						//memberVO.setIdcard_reason("身份信息不真实或资料填写有误！");
						memberVO.setIdcard_reason("身份证号码有误，请重试");
						memberVO.setIdcard_back_img(null);
						memberVO.setIdcard_front_img(null);
						dao.newUpdateIdCardInfo(memberVO);
					}
				}else{
					if("210301".equals(msg.get("error_code").toString())){
						//memberVO.setIdcard_reason("身份信息不真实或资料填写有误！");
						memberVO.setIdcard_reason("身份证号码有误，请重试");

					}
					if("210304".equals(msg.get("error_code").toString())){
						//memberVO.setIdcard_reason("身份证号错误，或同一身份证请求过于频繁");
						memberVO.setIdcard_reason("身份证号码有误，请重试");

					}
					if("10012".equals(msg.get("error_code").toString())){
						//memberVO.setIdcard_reason("请求异常，请联客服人员");
						memberVO.setIdcard_reason("身份证号码有误，请重试");
					}
					memberVO.setIdcard_state("3");
					dao.newUpdateIdCardInfo(memberVO);
				}
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			} 
		}else{
			if(vo.getIdcard_front_img()!=null && vo.getIdcard_back_img()!=null){
				memberVO.setIdcard_front_img(vo.getIdcard_front_img());
				memberVO.setIdcard_back_img(vo.getIdcard_back_img());
			}
			dao.newUpdateIdCardInfo(memberVO);
		}
		return msg;
	}
	
	public MemberVO getMemberByIdCheck(String member_id, String token, String os) {
		return dao.getMemberByIdCheck(member_id, token, os);
	}
	
	public String getChildIds(String member_id) {
		return dao.getChildIds(member_id);
	}
	
	public String getInvitedByUpdate(String member_id) throws Exception {
		//1.被邀请时间超过一周  2.等级不变 3.下线等级不变
		String childs = dao.getChildIds(member_id);
		 String re = dao.getInvitedByUpdate(member_id,childs, PropertieUtil.loadPropertie("primary_level"));
		 return "0".equals(re)?"1":"0";
	}

	public MemberVO getLoginMemberBySinaId(String sina_id) {
		return dao.getLoginMemberBySinaId(sina_id) ;
	}

	public MemberVO getLoginMemberByQQId(String qq_id) {
		return dao.getLoginMemberByQQId( qq_id) ;
	}
	
	public String getCidById(String id) {
		return dao.getCidById(id);
	}
	
	public String getUpExpertNum(String member_id, String expert_level) {
		String child_ids =  dao.getChildIds(member_id);
		return dao.getUpExpertNum(member_id, child_ids, expert_level);
	}
	
	public void insertConnTable(MemberVO memberVO) {
		//消息关联表数据生成
		dao.insertMsgConn(memberVO);
	}

	public MemberVO selectmMemberTable(String member_id) {
		return dao.selectmMemberTable(member_id);
	}
	public String getInvitenoById(String header_member_id) {
		return dao.getInvitenoById(header_member_id);
	}
	public MemberVO seleceMemerSomeInfo(String member_id) {
		// TODO Auto-generated method stub
		return dao.seleceMemerSomeInfo(member_id);
	}
	
	public List<Map<String, Object>> getOpenIdAll() {
		return dao.getOpenIdAll();
	}
	
	public void updateOpendIdBatch(String openid, String uid) {
		dao.updateOpendIdBatch(openid, uid);
	}

	public void updataPushOpenId(String member_id, String push_open_id) {
		dao.updataPushOpenId(member_id,push_open_id);
	}

	public void insertOpenIdAndPushOpenId(String push_open_id, String union_id) {
		dao.insertOpenIdAndPushOpenId(push_open_id,union_id);
	}

	@Override
	public MemberVO selectMemberInfoByUnionId(String union_id) {
		return dao.selectMemberInfoByUnionId(union_id);
	}

	@Override
	public List<String> getShangXianMemberId(String connNo) {
		return dao.getShangXianMemberId(connNo);
	}

	@Override
	public List<String> getShangXianMemberIdByOrderId(String order_id) {
		return dao.getShangXianMemberIdByOrderId(order_id);
	}
	
	@Override
	public void updatePushOpenId(String id, String push_open_id) {
		dao.updatePushOpenId(id, push_open_id);
	}

	@Override
	public void deleteMemberOpenByUnionId(String union_id) {
		dao.deleteMemberOpenByUnionId(union_id);
	}
	@Override
	public String getNickName(String create_by) {
		return dao.getNickName(create_by);
	}

	@Override
	public String getNickNameByConnNO(String connNo) {
		return dao.getNickNameByConnNO(connNo);
	}

	@Override
	public MemberVO getSimpleInfoByInviteNo(String invite_no) {
		return dao.getSimpleInfoByInviteNo(invite_no);
	}

	@Override
	public MemberVO packPaginationInfo(MemberVO memberVO) {
		MemberVO pagination = new MemberVO();
		pagination.setPage_index(memberVO.getPage_index());
		pagination.setPage_size(memberVO.getPage_size());
		pagination.setPage_count(memberVO.getPage_count());
		pagination.setTotal(memberVO.getTotal());
		return pagination;
	}


	public AddressVO getMemberAddress(String member_id, String address_id, String lang) {
		AddressVO address = new AddressVO();
		if(address_id!=null&&!"".equals(address_id)){
			if(lang==null){
				address = dao.getMemberAddressById(address_id);
			}else{
				address = dao.getMemberAddressByIdEn(address_id);
			}
		}else{
			if(lang==null){
				address = dao.getMemberDefaultAddress(member_id);
			}else{
				address = dao.getMemberDefaultAddressEn(member_id);
			}
			
			if(address==null){
				if(lang==null){
					address = dao.getMemberAddressByMemberId(member_id);
				}else{
					address = dao.getMemberAddressByMemberIdEn(member_id);
					AddressVO addressVO = addressVOMapper.getAddressByIdEn(address.getAddress_id());
					address.setApt(addressVO.getApt());
					address.setApt(addressVO.getCountry_id());
					address.setApt(addressVO.getArea_code());
					address.setApt(addressVO.getCountry());
					address.setApt(addressVO.getProvince());
					address.setApt(addressVO.getCode());
					address.setApt(addressVO.getProvince_id());
				}
			}
		}
		return address;
	}
	@Override
	public int selectMemberCart(String address_id) {
		return dao.selectMemberCart(address_id);
	}

	
	public int selectLibCity(String city_id) {
		return dao.selectLibCity(city_id);
	}

	@Override
	public String getMemberLevelLogo(String level) {
		
		//String logo=configDao.loadConfig("MEMBER_LEVEL_LOGO"+level.trim());
		String logo=configDao.loadConfig("MEMBER_LEVEL_LOGO");
		
		return logo;
	}

	@Override
	public Map getCommonPopUpInfo(MemberVO memberVO, String os,String type, String lang) {
		Map map=new HashMap();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");  
		DateFormat sdf_en = new SimpleDateFormat("MMM.dd, yyyy",Locale.ENGLISH);  

		MemberMsgVO msgvo= new MemberMsgVO();
		MemberVO parent_memberVO=new MemberVO();
		String exp_msg="";
		String exp_past="";
		String rate="";
		String rate_en="";
		String str="";
		String level_name="";
		String parent_name="";
		String parent_logo="";
		String level_logo_img="";
		String host_url=configDao.loadConfig("HOST");
		Double rate_d=null;
		if(memberVO.getId()!=null&&memberVO.getMember_id()==null){
			memberVO.setMember_id(memberVO.getId());
		}
		if(memberVO.getId()==null&&memberVO.getMember_id()!=null){
			memberVO.setId(memberVO.getMember_id());
		}
		if(!"0".equals(memberVO.getExp_state())&&memberVO.getExp_state()!=null){
			 msgvo=dao.getMemberMsgAllInfo(memberVO.getMember_id());
			 if("1".equals(memberVO.getExp_state())){
				 rate=MemberLevelItemVOMapper.getRateByLevel(memberVO.getLevel());
			 }
			 if("2".equals(memberVO.getExp_state())){
				String level_p=MemberLevelItemVOMapper.getExpPastLevelOne(memberVO.getId());
				 rate=MemberLevelItemVOMapper.getRateByLevel(level_p);
			 }
			 
			 parent_memberVO= getAllInfoById(memberVO.getInvited_by());
			 if(rate!=null){
				 rate_d=Double.parseDouble(rate);
				 if(rate_d<1){
					 rate_d=rate_d*10 ;
				 }
				 rate=String.valueOf(rate_d);
				 
				 rate_en=String.valueOf(NumberUtil.formatDouble(100-(rate_d*100),2));
			 }
			 //体验会员
			 if("1".equals(memberVO.getExp_state())){
				 Date date1 = Date.valueOf(memberVO.getExp_date());
				 String date =sdf.format(date1);
				 String date_en =sdf_en.format(date1);
				 if(memberVO.getInvited_by()!=null){
					 parent_name =parent_memberVO.getNick_name();
					 parent_logo =parent_memberVO.getLogo();
					 if("1".equals(type)){
						 if(lang==null){
							 str="赠送了您"+rate+"折会员折扣体验券（1个月）有效期至"+date;
						 }else{
							 str="send you "+rate+"% off experienced ticket (valid in 30 days) as gift."+date_en;
						 }
					 }
				 }else{
					 str="";
				 }
				
				 if("2".equals(type)){
					 if(lang==null){
						 str="您的会员折扣体验期截止至"+date+"<br>如想继续享受会员更多权益可开通对应会员级别";
					 }else{
						 str="ticket well expire in"+date_en+"please upgrade if you want to enjoy more priorities.";
					 }
					 
					 level_name=dicService.getNameById(memberVO.getLevel());
					 
					 if("2".equals(memberVO.getDic_other())){
						 level_logo_img=host_url+"/img/yinka.png";
					 }
					 if("3".equals(memberVO.getDic_other())){
						 level_logo_img=host_url+"/img/jinka.png";
					 }
					 if("4".equals(memberVO.getDic_other())){
						 level_logo_img=host_url+"/img/bojin.png";
					 }
					 if("5".equals(memberVO.getDic_other())){
						 level_logo_img=host_url+"/img/zhuanshi.png";
					 }
				 }
				 if("ios".equals(os)){
					 if("1".equals(type)){
						 if("Y".equals(msgvo.getExp_msg_ios())){
							 dao.updataMsgVoIosExpMsg(memberVO.getId());
						 }
						 map.put("state",msgvo.getExp_msg_ios());
					 }
					 if("2".equals(type)){
						 if("Y".equals(msgvo.getExp_member_ios())){
							 dao.updataMsgVoIosExpMemberMsg(memberVO.getMember_id());
						 }
						 map.put("state",msgvo.getExp_member_ios());
					 }
					 
				 }
				 if("android".equals(os)){
					 if("1".equals(type)){
						 if("Y".equals(msgvo.getExp_msg_android())){
							 dao.updataMsgVoAndroidExpMsg(memberVO.getId());
						 }
						 map.put("state",msgvo.getExp_msg_android());
					 }
					 if("2".equals(type)){
						 if("Y".equals(msgvo.getExp_member_android())){
							 dao.updataMsgVoAndroidExpMemberMsg(memberVO.getMember_id());
						 }
						 map.put("state",msgvo.getExp_member_android());
					 }
				 }
				 if("wechat".equals(os)){
					 if("1".equals(type)){
						 if("Y".equals(msgvo.getExp_msg_wechat())){
							 dao.updataMsgVoWechatExpMsg(memberVO.getId());
						 }
						 map.put("state",msgvo.getExp_msg_wechat());
					 }
					 if("2".equals(type)){
						 if("Y".equals(msgvo.getExp_member_wechat())){
							 dao.updataMsgVoWechatExpMemberMsg(memberVO.getMember_id());
						 }
						 map.put("state",msgvo.getExp_member_wechat());
					 }
				 }
				 if("web".equals(os)){
					 if("1".equals(type)){
						 if("Y".equals(msgvo.getExp_msg_web())){
							 dao.updataMsgVoWebExpMsg(memberVO.getId());
						 }
						 map.put("state",msgvo.getExp_msg_web());
					 }
					 if("2".equals(type)){
						 if("Y".equals(msgvo.getExp_member_web())){
							 dao.updataMsgVoWebExpMemberMsg(memberVO.getMember_id());
						 }
						 map.put("state",msgvo.getExp_member_web());
					 }
				 }
			 }
			 //体验结束
			 if("2".equals(memberVO.getExp_state())){
				 if(lang==null){
					 str="您的"+rate+"折会员折扣体验券（1个月）已到期，如想继续享受会员购物折扣和其他会员特权，请开通对应会员级别";
				 }else{
					 str="Your"+rate_en+"% off experienced ticket (valid in 30 days) has expired, if you want to enjoy the shopping discount and other priority, please upgrade.";
				 }
				
				 if("ios".equals(os)){
					 if("Y".equals(msgvo.getExp_past_msg_ios())){
						 dao.updataMsgVoIosExpPast(memberVO.getId());
					 }
					 map.put("state",msgvo.getExp_past_msg_ios());
				 }
				 if("android".equals(os)){
					 if("Y".equals(msgvo.getExp_past_msg_android())){
						 dao.updataMsgVoAndroidExpPast(memberVO.getId());
					 }
					 map.put("state",msgvo.getExp_past_msg_android());
				 }
				 if("wechat".equals(os)){
					 if("Y".equals(msgvo.getExp_past_msg_wechat())){
						 dao.updataMsgVoWechatExpPast(memberVO.getId());
					 }
					 map.put("state",msgvo.getExp_past_msg_wechat());
				 }
				 if("web".equals(os)){
					 if("Y".equals(msgvo.getExp_past_msg_web())){
						 dao.updataMsgVoWebExpPast(memberVO.getId());
					 }
					 map.put("state",msgvo.getExp_past_msg_web());
				 }
				 
			 }
			
		}else{
			map.put("state","");
			memberVO.setExp_state("0");
		}
		map.put("parent_name", parent_name);
		map.put("parent_logo", parent_logo);
		map.put("level_name", level_name);
		map.put("rate", rate);
		map.put("str", str);
		map.put("level_logo_img", level_logo_img);
		map.put("exp_state", memberVO.getExp_state()==null?"":memberVO.getExp_state());
		map.put("levelupinfo_url",configDao.loadConfig("HOST")+configDao.loadConfig("VERSION")+"/member/levelupInfo");
		
		return map;
	}

	@Override
	public List<PageEarnVO> getSuperBuyers(String lang) {
		 List<PageEarnVO> list =dao.getSuperBuyers(lang);
		 for(int i=0;i<list.size();i++){
			 list.get(i).setLogo(list.get(i).getLogo()+"?x-oss-process=image/resize,h_100");
		 }
		return list;
	}

	@Override
	public MemberVO popupPackage(Map map) {
		MemberVO popup_info=new MemberVO();
		popup_info.setLevel_logo_img((String) map.get("level_logo_img"));
		popup_info.setPopup_level_name((String) map.get("level_name"));
		popup_info.setPopup_rate((String) map.get("rate"));
		popup_info.setPopup_str((String) map.get("str"));
		popup_info.setExp_state((String) map.get("exp_state"));
		popup_info.setState((String) map.get("state"));
		return popup_info;
	}

	@Override
	public List<MemberVO> selectChildList(MemberVO memberVO) {
		return dao.selectChildList(memberVO);
	}
	@Override
	public MemberVO getMemberByTelAndCountry(MemberVO memberVO) {
		return dao.getMemberByTelAndCountry(memberVO);
	}
	@Override
	public int getMemberCountByTelAndCountry(MemberVO memberVO) {
		return dao.getMemberCountByTelAndCountry(memberVO);
	}

	@Override
	public int updateChildLevel(String child_member_id, String level) {
		return dao.updateChildLevel(child_member_id, level);
	}

	@Override
	public int getChildListTotal(MemberVO memberVO) {
		return dao.getChildListTotal(memberVO);
	}

	@Override
	public MemberVO getAllByInviteNo(String invite_no) {
		return dao.getAllByInviteNo(invite_no);
	}
	@Override
	public int getChildListTotalByLevel(MemberVO memberVO) {
		return dao.getChildListTotalByLevel(memberVO);
	}

	@Override
	public List<MemberVO> selectChildListByLevle(MemberVO memberVO) {
		return dao.selectChildListByLevle(memberVO);
	}

	@Override
	public void insertLogExp(String child_member_id, String level, String member_id) {
		dao.insertLogExp(child_member_id,level,member_id);
		
	}

	@Override
	public MemberVO getAllInfoByTelAndCountry_id(String tel, String country) {
		return dao.getAllInfoByTelAndCountry_id(tel,country);
	}

	@Override
	public void updateExpMsg(String id) {
		dao.updateExpMsg(id);
	}

	@Override
	public List<PageEarnVO> packageBuversPrice(List<PageEarnVO> super_buvers_) {
		List<PageEarnVO> super_buvers= super_buvers_ ;
		for(int i=0;i<super_buvers.size();i++){
			if(super_buvers.get(i).getCash()!=null){
				String cash =super_buvers.get(i).getCash();
				if(cash.indexOf(".00") > 0){
					  //正则表达
					cash = cash.replaceAll("0+?$", "");//去掉后面无用的零
					cash = cash.replaceAll("[.]$", "");//如小数点后面全是零则去掉小数点
				}
				super_buvers.get(i).setCash(cash);
			}
		}
		return super_buvers;
	}
	@Override
	public void updateGoogleId(MemberVO memberVO) {
		dao.updateGoogleId(memberVO);
	}
	@Override
	public MemberVO getLoginMemberByFacebookId(String facebook_id) {
		return dao.getLoginMemberByFacebookId(facebook_id);
	}
	@Override
	public void updateFacebookId(MemberVO memberVO) {
		dao.updateFacebookId(memberVO);
	}
	@Override
	public MemberVO getLoginMemberByVkontakteId(String vkontakte_id) {
		return dao.getLoginMemberByVkontakteId(vkontakte_id);
	}
	@Override
	public void updateVkontakteId(MemberVO memberVO) {
		dao.updateVkontakteId(memberVO);
	}
	@Override
	public void updatePayPal(MemberVO memberVO) {
		dao.updatePayPal(memberVO);
	}
	@Override
	public void updateInterAlipay(MemberVO memberVO) {
		dao.updateInterAlipay(memberVO);
	}
	
	@Override
	public void updateInterBank(MemberVO memberVO) {
		dao.updateInterBank(memberVO);
	}
	@Override
	public int checkFreeCashEn(MemberVO memberVO) {
		return dao.checkFreeCashEn(memberVO);
	}

	@Override
	public void updateInterIdCardInfo(MemberVO memberVO) {
		dao.updateInterIdCardInfo(memberVO);
	}
	@Override
	public MemberVO getInterIdcardInfo(String member_id) {
		return dao.getInterIdcardInfo(member_id);
	}
	@Override
	public int selectMemberCartEn(String address_id) {
		return dao.selectMemberCartEn(address_id);
	}

	@Override
	public MemberVO getDrawAccountInter(String member_id) {
		return dao.getDrawAccountInter(member_id);
	}
}
